<?php
    namespace app\admin\model;
    use think\Model;
    use think\request;
    use think\Db;

    
    class Teacher extends Model
    {

        public function t_list(){
            $map =[];
            //$map['Singer_Id'] = array('eq',2);
            $request = Request::instance();
            $data = $this->where($map)->order('User_id asc')->select();
            return $data;
        }

        public function tn_list(){
            $map =[];
            //$map['Singer_Id'] = array('eq',2);
            $request = Request::instance();
            $tnamedata = $this->where($map)->field('Rel_name')->select();
            return $tnamedata;
        }

        public function change_tn_list(){
            $map =[];
            //$map['Singer_Id'] = array('eq',2);
            $request = Request::instance();
            $t_namedata = $this->where($map)->field('Rel_name')->select();
            return $t_namedata;
        }

        public function insert($data){
            $username = $data['Name'];
            $password = $data['Password'];
            $relname = $data['Relname'];


            $result = Db::table('teacher')->insert([
                'User_name'=>$username,
                'User_password'=>$password,
                'Rel_name'=>$relname
            ]);

            if ($result) {
                return 1; //新添成功
            } else {
                return 2; //新添失败
            }
        }


    }
?>